---
title: Configure Log Streaming
sidebar_label: logs
---

By default, DevSpace streams the logs of all containers that use one of the images defined in the `images` section of the `devspace.yaml`.

To control which container logs should be streamed, you can configure the `dev.logs` section in the `devspace.yaml`.
```yaml {9-17}
images:
  frontend:
    image: gcr.io/my-org/appfrontend
  backend:
    image: john/appbackend
  database:
    image: john/database
dev:
  logs:
    showLast: 200
    # To display the sync log as well
    sync: true
    selectors:
    - imageSelector: john/appbackend
    - imageSelector: john/database
```

DevSpace will continously check what pods match the given selectors and start or end log streaming accordingly.

## Configuration

### `selectors`

DevSpaces allows log streaming from pods and containers based on label or image selectors. You can configure them under the option `selectors`.

```yaml
dev:
  logs:
    selectors:
    # Selects all pods with the given label selectors and streams the logs to the console
    - labelSelector:
        abc: def
      containerName: optional
      namespace: optional
    - labelSelector:
        other: selector   
    - imageSelector: nginx
      namespace: optional
```

### `sync`
The `sync` option expects an boolean which defines if the sync log should be merged with the pod and container logs. By default this option is true.

### `showLast`
The `showLast` option expects an integer which defines how many log lines DevSpace will print for each container before starting to stream the container's logs in real-time.

#### Default Value For `showLast`
```yaml
showLast: 50
```

#### Example: Show Last 200 Log Lines
```yaml {22}
images:
  frontend:
    image: john/appfrontend
  backend:
    image: john/appbackend
deployments:
- name: app-frontend
  helm:
    componentChart: true
    values:
      containers:
      - image: john/appfrontend
- name: app-backend
  helm:
    componentChart: true
    values:
      containers:
      - image: john/appbackend
      - image: john/appbackend-sidecar
dev:
  logs:
    showLast: 200
```
**Explanation:**  
- The above example defines 2 images and 2 deployments.
- DevSpace would stream the logs of:
  - The container of deployment `app-frontend` because the image is `john/appfrontend` = `images.frontend.image`
  - Only the first container of deployment `app-backend` because the image is `john/appbackend` = `images.backend.image`
- For each of the two containers, DevSpace would print the last 200 log lines before starting to stream the logs


### `disabled`
The `disabled` option expects a boolean which defines if DevSpace should start multi-container log streaming when running `devspace dev` or if DevSpace should just start other services (e.g. port-forwarding and sync) without starting the log stream.

#### Default Value For `disabled`
```yaml
disabled: false
```

#### Example: Disable Log Streaming
```yaml {14}
images:
  backend:
    image: john/appbackend
deployments:
- name: app-backend
  helm:
    componentChart: true
    values:
      containers:
      - image: john/appbackend
      - image: john/appbackend-sidecar
dev:
  logs:
    disabled: true
```
